package com.xca.is.repository;

import com.xca.is.entity.VideoEntity;
import com.xca.is.service.VideoService;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;


//https://api.mhimg.cn/api/New_gaoxiao_video/
public class VideoRepository {
    private static final String URL = "https://api.mhimg.cn/api/";
//    private static final String URL = "https://api.nuoyo.cn/api/";
    private VideoService service ;
    public VideoRepository(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(URL)
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        service = retrofit.create(VideoService.class);
    }
    public Observable<VideoEntity> getData(){
        return  service.getData()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
}
